package com.base.controller;

import com.base.po.voip.*;
import com.base.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

@Controller
@RequestMapping("/admin")
public class update_CompanyArticle {
	@Autowired
	private LogsService logsService;// log日志
	@Autowired
	private CompanyClassifyService companyClassifyService;
	@Autowired
	private CompanyArticleService companyArticleService;
	@Autowired
	private UsersService usersService;

	String SUCCESS = "success";

	// 更改商户信息
	@RequestMapping(value = "/updateCompanyArticle", method = RequestMethod.POST)
	public void updateSelfGoods(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(value = "id", required = true) Integer id, Byte datastatus) throws Exception {
		// 返回参数
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=UTF-8");
	
		CompanyArticle companyArticle = companyArticleService.selectByPrimaryKey(id);
		PrintWriter out = response.getWriter();

		companyArticle.setDatastatus(datastatus);

		int code = 0;
		if (id == null) {
			out.print("浏览器在点击的过程中发现丢失了用户信息，请您刷新重试！");
			return;
		} else {
			code = companyArticleService.updateByPrimaryKeySelective(companyArticle);
			if (code == 1) {
				out.print(SUCCESS);
			} else {
				out.print("更改失败，请您重试");
			}
		}
	}
}
